﻿using System.Data;


namespace DAL
{
    public static class DalForm
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetForm(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_Form_Get");
        }
        public static DataTable GetFormEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_Form", id);
            return Cls.GetData("sp_Form_Get_Edit");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtForm obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Form_Code", obj.Form_Code);
            Cls.AddParameter("@Form_Name", obj.Form_Name);
            Cls.AddParameter("@Note", obj.Note);
            Cls.AddParameter("@AttFile", obj.AttFile);
            Cls.AddParameter("@CreateDate", obj.CreateDate);
            return Cls.ExecuteNonQuery("sp_Form_Insert");
        }
        public static bool Update(EtForm obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_Form", obj.ID_Form);
            Cls.AddParameter("@Form_Code", obj.Form_Code);
            Cls.AddParameter("@Form_Name", obj.Form_Name);
            Cls.AddParameter("@Note", obj.Note);
            Cls.AddParameter("@AttFile", obj.AttFile);
            Cls.AddParameter("@CreateDate", obj.CreateDate);
            return Cls.ExecuteNonQuery("sp_Form_Update");
        }
        public static bool Delete(EtForm obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_Form", obj.ID_Form);
            return Cls.ExecuteNonQuery("sp_Form_Delete");
        }
        #endregion
    }

    public class EtForm
    {
        public int ID_Form { get; set; }
        public string Form_Code { get; set; }
        public string Form_Name { get; set; }
        public string Note { get; set; }
        public string AttFile { get; set; }
        public string CreateDate { get; set; }
    }
}